//
// Created by 11510 on 2024/7/4.
//

#ifndef DAY71_CONDITION_H
#define DAY71_CONDITION_H
#include <pthread.h>
#include "MutexLock.h"
class Condition {
private:
    pthread_cond_t cond;
public:
    Condition(){
        pthread_cond_init(&cond, NULL);
    }
    ~Condition(){
        pthread_cond_destroy(&cond);
    }
    void signal(){
        pthread_cond_signal(&cond);
    }
    void broadcast(){
        pthread_cond_broadcast(&cond);
    }
    void wait(MutexLock& mutexLock){
        /* 重载取地址运算符 */
        pthread_cond_wait(&cond, &mutexLock);
    }
};


#endif //DAY71_CONDITION_H
